package com.fx.service.impl;

import cn.hutool.core.date.DateUtil;
import com.fx.entity.OrderItem;
import com.fx.mapper.OrderItemMapper;
import com.fx.service.OrderItemService;
import com.fx.util.IdWorker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service
public class OrderItemServiceImpl implements OrderItemService {
    @Autowired
    private OrderItemMapper orderItemMapper;
    @Autowired
    private IdWorker idWorker;

    @Override
    public OrderItem getById(String flId) {
        return orderItemMapper.getById(flId);
    }

    @Override
    public List<OrderItem> getList(Map<String, Object> map) {
        return orderItemMapper.queryList(map);
    }

    @Override
    public int getCount(Map<String, Object> map) {
        return orderItemMapper.queryCount(map);
    }

    @Override
    public int save(OrderItem orderItem) {
        orderItem.setFlId(String.valueOf(idWorker.nextId()));
        orderItem.setFlCreatedTime(DateUtil.now());
        return orderItemMapper.save(orderItem);
    }

    @Override
    public int updateById(OrderItem orderItem) {
        return orderItemMapper.updateById(orderItem);
    }

    @Override
    public int remove(String flId) {
        return orderItemMapper.remove(flId);
    }

    @Override
    public int batchRemove(String[] flIds) {
        return orderItemMapper.batchRemove(flIds);
    }

    @Override
    public List<OrderItem> getOrderItemByOrderId(String flId) {
        return orderItemMapper.queryItemByOrder(flId);
    }

}
